package GHM;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Block_Wall extends Block{
	Sprite sprite;
	public Block_Wall() {

	}
	public void initImage(Block[][] blocks,int thisx, int thisy) {
		int calcValue = 0;
		Block tempObject;
		try {
			tempObject = blocks[thisy+1][thisx-1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=1;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=1;
		}

		try {
			tempObject = blocks[thisy+1][thisx];
			if (tempObject instanceof Block_Wall) {
				calcValue+=2;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=2;
		}

		try {
			tempObject = blocks[thisy+1][thisx+1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=4;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=4;
		}

		try {
			tempObject = blocks[thisy][thisx-1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=8;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=8;
		}

		try {
			tempObject = blocks[thisy][thisx+1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=16;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=16;
		}

		try {
			tempObject = blocks[thisy-1][thisx-1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=32;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=32;
		}

		try {
			tempObject = blocks[thisy-1][thisx];
			if (tempObject instanceof Block_Wall) {
				calcValue+=64;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=64;
		}
		try {
			tempObject = blocks[thisy-1][thisx+1];
			if (tempObject instanceof Block_Wall) {
				calcValue+=128;
			}
		} catch (ArrayIndexOutOfBoundsException e ) {
			calcValue+=128;
		}
		sprite = StaticTextures_Walls.images[calcValue];
	}
	public void render(SpriteBatch sb, int x, int y) {
		sprite.setPosition(x,y);
		sprite.draw(sb);
	}

}
